package com.xiaoqi.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.xiaoqi.constant.MessageConstant;
import com.xiaoqi.pojo.PageResult;
import com.xiaoqi.pojo.Permission;
import com.xiaoqi.pojo.QueryPageBean;
import com.xiaoqi.pojo.Result;
import com.xiaoqi.service.PermissionService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author PC
 * creationTime: 2022/11/6 16:31
 */

@RequestMapping("/permission")
@RestController
public class PermissionController {

    @Reference
    private PermissionService permissionService;

    /**
     * 查询所有权限
     * @return
     */
    @GetMapping("/findAll")
    public Result findAll(@RequestParam(value = "currentPage",defaultValue = "1")Integer currentPage,
                          @RequestParam(value = "pageSize",defaultValue = "10")Integer pageSize,
                          @RequestParam(value = "queryString",defaultValue = "")String queryString){
        QueryPageBean queryPageBean = new QueryPageBean(currentPage, pageSize, queryString);
        PageResult pageResult = permissionService.findAll(queryPageBean);
        return new Result(true, MessageConstant.QUERY_PERMISSION_SUCCESS,pageResult);
    }
}
